package mdm.led.common;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.imageio.ImageIO;
import javax.swing.plaf.synth.Region;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class ExcelUtil {

	private static final Logger LOGGER = LoggerFactory.getLogger(ExcelUtil.class);

	
	/**
	 * 生成Excel工具类
	 * 
	 * @param path
	 *            文件保存路径
	 * @param list
	 *            Excel文件内容
	 * @return 生成的文件名称
	 */
//	public static HSSFWorkbook createTrafficDangerExcel(String path, List<TrafficDanger> list) {
//		try {
//			
//			// 第一步，创建一个webbook，对应一个Excel文件
//			HSSFWorkbook wb = new HSSFWorkbook();
//			// 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet
//			HSSFSheet sheet = wb.createSheet("交通隐患基本资料表");
////			sheet.setDefaultRowHeight((short) 330);
//			HSSFRow row = sheet.createRow((int) 0);
//			// 第四步，创建单元格，并设置值表头 设置表头居中
//			HSSFCellStyle style = wb.createCellStyle();
//			HSSFCellStyle style1 = wb.createCellStyle();
//			HSSFCellStyle cellStyle=wb.createCellStyle(); 
//			// style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
//			style.setFillForegroundColor(HSSFColor.CORNFLOWER_BLUE.index);// 设置背景色 SOLID_FOREGROUND
////			style.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
//			style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
//			
//			style.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
//			style.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
//			style.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
//			style.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
//			
//			// 设置边框
//			style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
//			style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
//			style1.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
//			style1.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
//			
//			cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
//			cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
//			cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
//			cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
////			cellStyle.setWrapText(true);
//			
//			HSSFCell cell = row.createCell((short) 0);
//			cell.setCellValue("序号");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 1);
//			cell.setCellValue("行政区");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 2);
//			cell.setCellValue("地点");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 3);
//			cell.setCellValue("路名和公里桩");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 4);
//			cell.setCellValue("道路类别");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 5);
//			cell.setCellValue("线性");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 6);
//			cell.setCellValue("路段情况和事故情况");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 7);
//			cell.setCellValue("主要隐患");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 8);
//			cell.setCellValue("隐患等级");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 9);
//			cell.setCellValue("整治建议");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 10);
//			cell.setCellValue("责任单位");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 11);
//			cell.setCellValue("跟进民警");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 12);
//			cell.setCellValue("跟进领导");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 13);
//			cell.setCellValue("是否销账");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 14);
//			cell.setCellValue("销账理由");
//			cell.setCellStyle(style);
//			
//			// 第五步，写入实体数据 实际应用中这些数据从数据库得到，
//			if (list != null) {
//				int maxIndexa = "序号".getBytes().length;
//				int maxIndexb = "行政区".getBytes().length;
//				int maxIndexc = "地点".getBytes().length;
//				int maxIndexd = "路名和公里桩".getBytes().length;
//				int maxIndexe = "道路类别".getBytes().length;
//				int maxIndexf = "线性".getBytes().length;
//				int maxIndexg = "路段情况和事故情况".getBytes().length;
//				int maxIndexh = "主要隐患".getBytes().length;
//				int maxIndexi = "隐患等级".getBytes().length;
//				int maxIndexj = "整治建议".getBytes().length;
//				int maxIndexk = "责任单位".getBytes().length;
//				int maxIndexl = "跟进民警".getBytes().length;
//				int maxIndexm = "跟进领导".getBytes().length;
//				int maxIndexn = "是否销账".getBytes().length;
//				int maxIndexo = "销账理由".getBytes().length;
//				for (int i = 0; i < list.size(); i++) {
//					TrafficDanger trafficDanger = list.get(i);
//					
//					row = sheet.createRow((int) i + 1); 
//					HSSFCell cell0 = row.createCell((short) 0);
//					int num = i+1;
//					cell0.setCellValue(num);  
//					cell0.setCellStyle(style1);
//					int as = String.valueOf(num).getBytes().length;
//					if(maxIndexa < as) {
//						maxIndexa = as;
//					}
//					
//				    HSSFCell cell1 = row.createCell((short) 1);
//				    cell1.setCellValue(trafficDanger.getDistrict());
//				    cell1.setCellStyle(style1);
//				    if(!(trafficDanger.getDistrict()==null||trafficDanger.getDistrict().equals(""))) {
//				    	int bs = cell1.getStringCellValue().getBytes().length;
//				    	if(maxIndexb < bs) {
//							maxIndexb = bs;
//						}   
//				    	
//				    }
//				    
//			        HSSFCell cell2 = row.createCell((short) 2);
//			        cell2.setCellValue(trafficDanger.getLocation());
//			        cell2.setCellStyle(style1);
//			        if(!(trafficDanger.getLocation()==null||trafficDanger.getLocation().equals(""))) {
//			        	int cs = cell2.getStringCellValue().getBytes().length;
//			        	if(maxIndexc < cs) {
//							maxIndexc = cs;
//						}   
//			        }
//			        
//		            HSSFCell cell3 = row.createCell((short) 3);
//		            cellStyle.setWrapText(true);
//		            cell3.setCellStyle(cellStyle);
//		            cell3.setCellValue(trafficDanger.getRoadName()); 
//		            if(!(trafficDanger.getRoadName()==null||trafficDanger.getRoadName().equals(""))) {
//			        	int ds = cell3.getStringCellValue().getBytes().length;
//			        	if(maxIndexd < ds) {
//							maxIndexd = ds;
//						}   
//			        }
//		            
//		            HSSFCell cell4 = row.createCell((short) 4);
//		            cellStyle.setWrapText(true);
//		            cell4.setCellStyle(cellStyle);
//		            cell4.setCellValue(trafficDanger.getType());  
//		            if(!(trafficDanger.getType()==null||trafficDanger.getType().equals(""))) {
//			        	int es = cell4.getStringCellValue().getBytes().length;
//			        	if(maxIndexe < es) {
//							maxIndexe = es;
//						}   
//			        }
//		            
//		            HSSFCell cell5 = row.createCell((short) 5);
//		            cell5.setCellValue(trafficDanger.getLinears());  
//		            cell5.setCellStyle(style1);
//		            if(!(trafficDanger.getLinears()==null||trafficDanger.getLinears().equals(""))) {
//		            	int fs = cell5.getStringCellValue().getBytes().length;
//		            	if(maxIndexf < fs) {
//							maxIndexf = fs;
//						}   
//		            	
//		            }
//		            
//		            HSSFCell cell6 = row.createCell((short) 6);
//		            cell6.setCellValue(trafficDanger.getSection());  
//		            cell6.setCellStyle(style1);
//		            if(!(trafficDanger.getSection()==null||trafficDanger.getSection().equals(""))) {
//		            	int gs = cell6.getStringCellValue().getBytes().length;
//		            	if(maxIndexg < gs) {
//							maxIndexg = gs;
//						}    
//		            }
//		            
//		            HSSFCell cell7 = row.createCell((short) 7);
//		            cell7.setCellValue(trafficDanger.getMainDanger());  
//		            cell7.setCellStyle(style1);
//		            if(!(trafficDanger.getMainDanger()==null||trafficDanger.getMainDanger().equals(""))) {
//		            	int hs = cell7.getStringCellValue().getBytes().length;
//		            	if(maxIndexh < hs) {
//							maxIndexh = hs;
//						}    
//		            }
//		            
//		            HSSFCell cell8 = row.createCell((short) 8);
//		            cell8.setCellValue(trafficDanger.getDangerGrade());  
//		            cell8.setCellStyle(style1);
//		            if(!(trafficDanger.getDangerGrade()==null||trafficDanger.getDangerGrade().equals(""))) {
//		            	int is = cell8.getStringCellValue().getBytes().length;
//		            	if(maxIndexi < is) {
//							maxIndexi = is;
//						}    
//		            }
//		            
//		            HSSFCell cell9 = row.createCell((short) 9);
//		            cell9.setCellValue(trafficDanger.getRectificationProposals());  
//		            cell9.setCellStyle(style1);
//		            if(!(trafficDanger.getRectificationProposals()==null||trafficDanger.getRectificationProposals().equals(""))) {
//		            	int js = cell9.getStringCellValue().getBytes().length;
//		            	if(maxIndexj < js) {
//							maxIndexj = js;
//						}    
//		            }
//		            
//		            HSSFCell cell10 = row.createCell((short) 10);
//		            cell10.setCellValue(trafficDanger.getDutyUnit());  
//		            cell10.setCellStyle(style1);
//		            if(!(trafficDanger.getDutyUnit()==null||trafficDanger.getDutyUnit().equals(""))) {
//		            	int ks = cell10.getStringCellValue().getBytes().length;
//		            	if(maxIndexk < ks) {
//							maxIndexk = ks;
//						}    
//		            }
//		            
//		            HSSFCell cell11 = row.createCell((short) 11);
//		            cell11.setCellValue(trafficDanger.getFollowPolice());  
//		            cell11.setCellStyle(style1);
//		            if(!(trafficDanger.getSection()==null||trafficDanger.getSection().equals(""))) {
//		            	int ls = cell11.getStringCellValue().getBytes().length;
//		            	if(maxIndexl < ls) {
//							maxIndexl = ls;
//						}    
//		            }
//		            
//		            HSSFCell cell12 = row.createCell((short) 12);
//		            cell12.setCellValue(trafficDanger.getFollowLeader());  
//		            cell12.setCellStyle(style1);
//		            if(!(trafficDanger.getSection()==null||trafficDanger.getSection().equals(""))) {
//		            	int ms = cell12.getStringCellValue().getBytes().length;
//		            	if(maxIndexm < ms) {
//							maxIndexm = ms;
//						}    
//		            }
//		            
//		            HSSFCell cell13 = row.createCell((short) 13);
//		            System.out.println("status====="+trafficDanger.getStatus());
//		            if(!(trafficDanger.getStatus() == null || trafficDanger.getStatus().equals("")) ) {
//		            	if(trafficDanger.getStatus() == (short) 1) {
//			            	cell13.setCellValue("是");  
//			            }else if(trafficDanger.getStatus() == (short) 2) {
//			            	cell13.setCellValue("否");  
//			            }
//		            }else {
//		            	cell13.setCellValue("");
//		            }
//		            
//		            cell13.setCellStyle(style1);
//		            if(!(trafficDanger.getStatus()==null||trafficDanger.getStatus().equals(""))) {
//		            	int ns = cell13.getStringCellValue().getBytes().length;
//		            	if(maxIndexn < ns) {
//							maxIndexn = ns;
//						}    
//		            }
//		            
//		            HSSFCell cell14 = row.createCell((short) 14);
//		            cell14.setCellValue(trafficDanger.getOffReason());  
//		            cell14.setCellStyle(style1);
//		            if(!(trafficDanger.getOffReason()==null||trafficDanger.getOffReason().equals(""))) {
//		            	int os = cell14.getStringCellValue().getBytes().length;
//		            	if(maxIndexo < os) {
//							maxIndexo = os;
//						}    
//		            }
//		            
//				}
//				sheet.setColumnWidth(0, (maxIndexa + 1) * 256);
//				sheet.setColumnWidth(1, (maxIndexb + 1) * 256);
//				sheet.setColumnWidth(2, (maxIndexc + 1) * 256);
//				sheet.setColumnWidth(3, (maxIndexd + 1) * 256);
//				sheet.setColumnWidth(4, (maxIndexe + 1) * 256);
//				sheet.setColumnWidth(5, (maxIndexf + 1) * 256);
//				sheet.setColumnWidth(6, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(7, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(8, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(9, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(10, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(11, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(12, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(13, (maxIndexg + 1) * 256);
//				sheet.setColumnWidth(14, (maxIndexg + 1) * 256);
//			}
//			
//			sheet.setMargin(HSSFSheet.TopMargin, 0.2);
//			sheet.setMargin(HSSFSheet.BottomMargin, 0.2);
//			sheet.setMargin(HSSFSheet.LeftMargin, 0.2);
//			sheet.setMargin(HSSFSheet.RightMargin, 0.2);
//			sheet.getPrintSetup().setHeaderMargin(0.315);
//			sheet.getPrintSetup().setFooterMargin(0.315);
//			return wb;
//		} catch (Exception e) {
//			LOGGER.error("", e);
//			return null;
//		}
//	}
	
	/**
	 * 生成Excel工具类
	 * 
	 * @param path
	 *            文件保存路径
	 * @param list
	 *            Excel文件内容
	 * @return 生成的文件名称
	 */
//	public static HSSFWorkbook createThreeCheckExcel(String path, List<ThreeCheck> list) {
//		try {
//			
//			// 第一步，创建一个webbook，对应一个Excel文件
//			HSSFWorkbook wb = new HSSFWorkbook();
//			// 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet
//			HSSFSheet sheet = wb.createSheet("交通隐患基本资料表");
////			sheet.setDefaultRowHeight((short) 330);
//			HSSFRow row = sheet.createRow((int) 0);
//			// 第四步，创建单元格，并设置值表头 设置表头居中
//			HSSFCellStyle style = wb.createCellStyle();
//			HSSFCellStyle style1 = wb.createCellStyle();
//			HSSFCellStyle cellStyle=wb.createCellStyle(); 
//			// style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
//			style.setFillForegroundColor(HSSFColor.CORNFLOWER_BLUE.index);// 设置背景色 SOLID_FOREGROUND
////			style.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
//			style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
//			
//			style.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
//			style.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
//			style.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
//			style.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
//			
//			// 设置边框
//			style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
//			style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
//			style1.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
//			style1.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
//			
//			cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
//			cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
//			cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
//			cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
////			cellStyle.setWrapText(true);
//			
//			HSSFCell cell = row.createCell((short) 0);
//			cell.setCellValue("序号");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 1);
//			cell.setCellValue("三查表名称");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 2);
//			cell.setCellValue("状态");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 3);
//			cell.setCellValue("自查人");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 4);
//			cell.setCellValue("检查人");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 5);
//			cell.setCellValue("抽查人");
//			cell.setCellStyle(style);
//			cell = row.createCell((short) 6);
//			cell.setCellValue("检查日期");
//			cell.setCellStyle(style);
////			cell = row.createCell((short) 7);
////			cell.setCellValue("主要隐患");
////			cell.setCellStyle(style);
////			cell = row.createCell((short) 8);
////			cell.setCellValue("隐患等级");
////			cell.setCellStyle(style);
////			cell = row.createCell((short) 9);
////			cell.setCellValue("整治建议");
////			cell.setCellStyle(style);
////			cell = row.createCell((short) 10);
////			cell.setCellValue("责任单位");
////			cell.setCellStyle(style);
////			cell = row.createCell((short) 11);
////			cell.setCellValue("跟进民警");
////			cell.setCellStyle(style);
////			cell = row.createCell((short) 12);
////			cell.setCellValue("跟进领导");
////			cell.setCellStyle(style);
////			cell = row.createCell((short) 13);
////			cell.setCellValue("是否销账");
////			cell.setCellStyle(style);
////			cell = row.createCell((short) 14);
////			cell.setCellValue("销账理由");
////			cell.setCellStyle(style);
//			
//			// 第五步，写入实体数据 实际应用中这些数据从数据库得到，
//			if (list != null) {
//				int maxIndexa = "序号".getBytes().length;
//				int maxIndexb = "三查表名称".getBytes().length;
//				int maxIndexc = "状态".getBytes().length;
//				int maxIndexd = "自查人".getBytes().length;
//				int maxIndexe = "检查人".getBytes().length;
//				int maxIndexf = "抽查人".getBytes().length;
//				int maxIndexg = "检查日期".getBytes().length;
////				int maxIndexh = "主要隐患".getBytes().length;
////				int maxIndexi = "隐患等级".getBytes().length;
////				int maxIndexj = "整治建议".getBytes().length;
////				int maxIndexk = "责任单位".getBytes().length;
////				int maxIndexl = "跟进民警".getBytes().length;
////				int maxIndexm = "跟进领导".getBytes().length;
////				int maxIndexn = "是否销账".getBytes().length;
////				int maxIndexo = "销账理由".getBytes().length;
//				for (int i = 0; i < list.size(); i++) {
//					ThreeCheck threeCheck = list.get(i);
//					
//					row = sheet.createRow((int) i + 1); 
//					HSSFCell cell0 = row.createCell((short) 0);
//					int num = i+1;
//					cell0.setCellValue(num);  
//					cell0.setCellStyle(style1);
//					int as = String.valueOf(num).getBytes().length;
//					if(maxIndexa < as) {
//						maxIndexa = as;
//					}
//					
//					HSSFCell cell1 = row.createCell((short) 1);
//					cell1.setCellValue(threeCheck.getCheckName());
//					cell1.setCellStyle(style1);
//					if(!(threeCheck.getCheckName()==null||threeCheck.getCheckName().equals(""))) {
//						int bs = cell1.getStringCellValue().getBytes().length;
//						if(maxIndexb < bs) {
//							maxIndexb = bs;
//						}   
//						
//					}
//					
//					HSSFCell cell2 = row.createCell((short) 2);
//					
//					if(!(threeCheck.getStatus() == null || threeCheck.getStatus().equals("")) ) {
//						if(threeCheck.getStatus() == (short) 1) {
//							cell2.setCellValue("检查通过");
//						} else if(threeCheck.getStatus() == (short) 2) {
//							cell2.setCellValue("自查已完成");
//						} else if(threeCheck.getStatus() == (short) 3) {
//							cell2.setCellValue("抽查通过");
//						} else if(threeCheck.getStatus() == (short) 4) {
//							cell2.setCellValue("检查、抽查不通过");
//						}
//					} else {
//						cell2.setCellValue("");
//					}
//					cell2.setCellStyle(style1);
//					if(!(threeCheck.getStatus()==null||threeCheck.getStatus().equals(""))) {
//						int cs = cell2.getStringCellValue().getBytes().length;
//						if(maxIndexc < cs) {
//							maxIndexc = cs;
//						}   
//					}
//					
//					HSSFCell cell3 = row.createCell((short) 3);
//					cellStyle.setWrapText(true);
//					cell3.setCellStyle(cellStyle);
//					cell3.setCellValue(threeCheck.getSelfRole()); 
//					if(!(threeCheck.getSelfRole()==null||threeCheck.getSelfRole().equals(""))) {
//						int ds = cell3.getStringCellValue().getBytes().length;
//						if(maxIndexd < ds) {
//							maxIndexd = ds;
//						}   
//					}
//					
//					HSSFCell cell4 = row.createCell((short) 4);
//					cellStyle.setWrapText(true);
//					cell4.setCellStyle(cellStyle);
//					cell4.setCellValue(threeCheck.getCheckRole());  
//					if(!(threeCheck.getCheckRole()==null||threeCheck.getCheckRole().equals(""))) {
//						int es = cell4.getStringCellValue().getBytes().length;
//						if(maxIndexe < es) {
//							maxIndexe = es;
//						}   
//					}
//					
//					HSSFCell cell5 = row.createCell((short) 5);
//					cell5.setCellValue(threeCheck.getRandomRole());  
//					cell5.setCellStyle(style1);
//					if(!(threeCheck.getRandomRole()==null||threeCheck.getRandomRole().equals(""))) {
//						int fs = cell5.getStringCellValue().getBytes().length;
//						if(maxIndexf < fs) {
//							maxIndexf = fs;
//						}   
//						
//					}
//					
//					HSSFCell cell6 = row.createCell((short) 6);
//					cell6.setCellValue(threeCheck.getCheckDate());  
//					cell6.setCellStyle(style1);
//					if(!(threeCheck.getCheckDate()==null||threeCheck.getCheckDate().equals(""))) {
//						int gs = cell6.getStringCellValue().getBytes().length;
//						if(maxIndexg < gs) {
//							maxIndexg = gs;
//						}    
//					}
//					
////					HSSFCell cell7 = row.createCell((short) 7);
////					cell7.setCellValue(trafficDanger.getMainDanger());  
////					cell7.setCellStyle(style1);
////					if(!(trafficDanger.getMainDanger()==null||trafficDanger.getMainDanger().equals(""))) {
////						int hs = cell7.getStringCellValue().getBytes().length;
////						if(maxIndexh < hs) {
////							maxIndexh = hs;
////						}    
////					}
////					
////					HSSFCell cell8 = row.createCell((short) 8);
////					cell8.setCellValue(trafficDanger.getDangerGrade());  
////					cell8.setCellStyle(style1);
////					if(!(trafficDanger.getDangerGrade()==null||trafficDanger.getDangerGrade().equals(""))) {
////						int is = cell8.getStringCellValue().getBytes().length;
////						if(maxIndexi < is) {
////							maxIndexi = is;
////						}    
////					}
////					
////					HSSFCell cell9 = row.createCell((short) 9);
////					cell9.setCellValue(trafficDanger.getRectificationProposals());  
////					cell9.setCellStyle(style1);
////					if(!(trafficDanger.getRectificationProposals()==null||trafficDanger.getRectificationProposals().equals(""))) {
////						int js = cell9.getStringCellValue().getBytes().length;
////						if(maxIndexj < js) {
////							maxIndexj = js;
////						}    
////					}
////					
////					HSSFCell cell10 = row.createCell((short) 10);
////					cell10.setCellValue(trafficDanger.getDutyUnit());  
////					cell10.setCellStyle(style1);
////					if(!(trafficDanger.getDutyUnit()==null||trafficDanger.getDutyUnit().equals(""))) {
////						int ks = cell10.getStringCellValue().getBytes().length;
////						if(maxIndexk < ks) {
////							maxIndexk = ks;
////						}    
////					}
////					
////					HSSFCell cell11 = row.createCell((short) 11);
////					cell11.setCellValue(trafficDanger.getFollowPolice());  
////					cell11.setCellStyle(style1);
////					if(!(trafficDanger.getSection()==null||trafficDanger.getSection().equals(""))) {
////						int ls = cell11.getStringCellValue().getBytes().length;
////						if(maxIndexl < ls) {
////							maxIndexl = ls;
////						}    
////					}
////					
////					HSSFCell cell12 = row.createCell((short) 12);
////					cell12.setCellValue(trafficDanger.getFollowLeader());  
////					cell12.setCellStyle(style1);
////					if(!(trafficDanger.getSection()==null||trafficDanger.getSection().equals(""))) {
////						int ms = cell12.getStringCellValue().getBytes().length;
////						if(maxIndexm < ms) {
////							maxIndexm = ms;
////						}    
////					}
////					
////					HSSFCell cell13 = row.createCell((short) 13);
////					if(trafficDanger.getStatus() == 1) {
////						cell13.setCellValue("是");  
////					}else if(trafficDanger.getStatus() == 2) {
////						cell13.setCellValue("否");  
////					}else {
////						cell13.setCellValue("");
////					}
////					cell13.setCellStyle(style1);
////					if(!(trafficDanger.getStatus()==null||trafficDanger.getStatus().equals(""))) {
////						int ns = cell13.getStringCellValue().getBytes().length;
////						if(maxIndexn < ns) {
////							maxIndexn = ns;
////						}    
////					}
////					
////					HSSFCell cell14 = row.createCell((short) 14);
////					cell14.setCellValue(trafficDanger.getOffReason());  
////					cell14.setCellStyle(style1);
////					if(!(trafficDanger.getOffReason()==null||trafficDanger.getOffReason().equals(""))) {
////						int os = cell14.getStringCellValue().getBytes().length;
////						if(maxIndexo < os) {
////							maxIndexo = os;
////						}    
////					}
//					
//				}
//				sheet.setColumnWidth(0, (maxIndexa + 1) * 256);
//				sheet.setColumnWidth(1, (maxIndexb + 1) * 256);
//				sheet.setColumnWidth(2, (maxIndexc + 1) * 256);
//				sheet.setColumnWidth(3, (maxIndexd + 1) * 256);
//				sheet.setColumnWidth(4, (maxIndexe + 1) * 256);
//				sheet.setColumnWidth(5, (maxIndexf + 1) * 256);
//				sheet.setColumnWidth(6, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(7, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(8, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(9, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(10, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(11, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(12, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(13, (maxIndexg + 1) * 256);
////				sheet.setColumnWidth(14, (maxIndexg + 1) * 256);
//			}
//			
//			sheet.setMargin(HSSFSheet.TopMargin, 0.2);
//			sheet.setMargin(HSSFSheet.BottomMargin, 0.2);
//			sheet.setMargin(HSSFSheet.LeftMargin, 0.2);
//			sheet.setMargin(HSSFSheet.RightMargin, 0.2);
//			sheet.getPrintSetup().setHeaderMargin(0.315);
//			sheet.getPrintSetup().setFooterMargin(0.315);
//			return wb;
//		} catch (Exception e) {
//			LOGGER.error("", e);
//			return null;
//		}
//	}
	
}
